/*
 * @Author: xiaosihan 
 * @Date: 2023-11-18 00:56:42 
 * @Last Modified by: xiaosihan
 * @Last Modified time: 2024-06-25 04:18:38
 */

import loginApi from "@api/loginAPI";
import queryString from "query-string";

const getQueryString = (key: string) => {
    const parsedHash = queryString.parse(location.search);
    return parsedHash[key] || "";
}


const code = getQueryString("code") as string;

if (code) {
    loginApi.wx_Login_get_access_token({ code }).then((res: any) => {
        if (res.token) {
            if (top) {
                top.localStorage.setItem('token', res.token);
            } else {
                localStorage.setItem('token', res.token);
            }
        } else {
            console.error('微信登录报错', res.data)
        }
    })
}
